package com.southpark.demo.control.proxies.user
{
	import com.southpark.demo.control.proxies.BaseProxy;
	import com.southpark.demo.enum.ServerErrorEnum;
	import com.southpark.demo.services.ServerErrorCodes;
	import com.southpark.framework.control.responders.IResponder;
	
	import lab.southpark.demo.services.fake.user.FakeUserLoginService;
	
	
	
	public class UserLoginProxy extends BaseProxy
	{
		
		public function UserLoginProxy(responder:IResponder)
		{
			super(responder,FakeUserLoginService,FakeUserLoginService);
		}
		
		public function execute(userName:String,password:String):void
		{
			callService(this,"userLogin",[userName,password]);
		}
		
		
		override public function manageSuccess(data:Object):Object
		{
			return data["sessionId"];
		}
		
		override public function manageFault(faultCode:String):String
		{
			if (faultCode == ServerErrorCodes.ERROR_0001)
			{
				return ServerErrorEnum.LOGIN_ERROR.itsString;
			};
			
			return null;
		}
	
	}
}